#ifndef _DISK_DEV_BLK_H_
#define _DISK_DEV_BLK_H_

#include <stdint.h>
#include <stdio.h>

#define _FILE_OFFSET_BITS 64
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
//#include <pthread.h>
#include <mutex>
using namespace std;
class CDiskBlk
{
public:
	CDiskBlk();
	~CDiskBlk();
	int Open(const char * device, int acess_mod);
	int Close();
	int Write(uint64_t lba, unsigned char* data_buf, uint32_t data_size, bool bLock = true);
	int Read(uint64_t lba, unsigned char* data_buf, uint32_t data_size, bool bLock = true);
	int Flush();

	uint64_t ReadCapacity(uint32_t * psec_size = NULL);
	int ReScanPartTable();
	char* get_device_name()
	{
		return m_device;
	}
	uint64_t get_capacity()
	{
		return m_capacity;
	}
	uint32_t get_sec_size()
	{
		return m_sec_size;
	}
protected:
	int      m_fd;
	char     m_device[64];
	int      m_access_mod;
	uint64_t m_capacity;// = capability >> 9;
	uint64_t m_sec_size;// = 512;
	mutex  m_mutex;
};


#endif